<html>
	<head>
		<title>UNIT TEST :: </title>
	</head>
	<script>
		function get_http_object() {
			return window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
		};
		
		function onChangeSystem()
		{
			var cboSystem = document.getElementById('cboSystem');
			var divManager = document.getElementById('divManager');
			var divService = document.getElementById('divService');
			
			if(cboSystem[0].selected)//application
			{
				divManager.style.display = "block";
				divService.style.display = "none";
				
			}
			else//service
			{
				divManager.style.display = "none";
				divService.style.display = "block";
			}
			onChangeExample();
		}
		
		function checkSubmit()
		{

			var frmUnitTest = document.getElementById('frmUnittest');
			var cboSystem = document.getElementById('cboSystem');
			frmUnitTest.action = "http://localhost:8501/confluence/service/src/service.cfc?method=request";
			if(cboSystem[0].selected)//application
			{
				frmUnitTest.action = "http://localhost:8501/confluence/manager/src/manager.cfc?method=request";
			}
			return true;
			
		}
		
		
		
		function onChangeExample()
		{
			var cboExample = document.getElementById('cboExample');
			var textdata = document.getElementById('data');
			
			var xmlPath = 'http://localhost:8501/confluence/unittest/example/xml/';
			for(var i = 0; i < cboExample.length; i++)
			{
				if(cboExample[i].selected)//User
				{
					var tmp = Math.floor(Math.random()*1111)
					xmlPath += cboExample[i].value + '.xml?' + tmp ;
				}
			}
			textdata.value = "Cargando...";
			var con = get_http_object();
			con.onreadystatechange = function() {
				//alert ('con.readyState:'+con.readyState + " con.status:" + con.status);	
				if (con.readyState == 4 && con.status == 200)
				{	
					
					textdata.value = con.responseText;										
				}
				if (con.readyState == 4 && con.status == 404)
				{
					textdata.value = 'no example selected';	
				}
			}
			var acon = navigator.appName == "Microsoft Internet Explorer" ? false : true;
			con.open("POST",xmlPath,acon);
			con.send(null);
			
		}
		
		
		
		
	</script>
	
	
	<body onload="onChangeSystem()">
		<cfoutput>
			admin with md5: #Hash('admin')#
		</cfoutput>
		
		<form 
			method="post" 
			name="frmUnittest" 
			id="frmUnittest">
			
			system:
			<select name="cboSystem" id="cboSystem" onChange="onChangeSystem()">
				<option value="Manager">Manager</option>
				<option value="Service">Service</option>
			</select>
			<br /><br /><br />
			module: <input name="module" type="text" value="User"><br />
			action: <input name="action" type="text" value="create"><br />
			inputData:<input name="inputData" type="text" value="xml"><br />
			returnData:<input name="outputData" type="text" value="xml"><br />
			<div id="divManager" style="display:none;">
				username: <input name="username" type="text" required="false"><br />
				password: <input name="password" type="text" required="false"><br />
			</div>
			<div id="divService" style="display:none;">
			token: <input name="token" type="text" required="false"><br />
			</div>
			example xml data:
			<select name="cboExample" id="cboExample" onChange="onChangeExample()">
				<option value="">Select</option>
				<option value="user_add">user_add</option>
				<option value="user_add">user_update</option>
				
			</select>
			<br />
			<br />
			data: <br />
			<textarea style="width: 600px; height:400px;" name="data" id="data"></textarea><br /><br />
			
			<input type="submit" name="btnSubmit" onclick="return checkSubmit()">
			
		</form>
	</body>
</html>